﻿using _15Net8AspNetCore_ORM.Models;
using SqlSugar;

namespace _15Net8AspNetCore_ORM.Context
{
    public class SqlSugarDBContext
    {
        public SqlSugarDBContext(IConfiguration configuration)
        {
            // 1、创建SqlSuggarClient
            _SqlSugarClient = new SqlSugarClient(
                new ConnectionConfig()
                {
                    ConnectionString = configuration.GetConnectionString("DefaultConnection"),
                    DbType = DbType.MySql,
                    IsAutoCloseConnection = true,
                });

            _SqlSugarClient.CodeFirst.InitTables<Order>();
        }

        public IConfiguration _Configuration { get; set; }

        public SqlSugarClient _SqlSugarClient { get; set; }

    }
}
